<?php

/**
 * This is the model class for table "po_detail".
 *
 * The followings are the available columns in table 'po_detail':
 * @property string $id
 * @property string $po_number
 * @property string $part_code
 * @property string $part_name
 * @property string $description
 * @property string $qty
 * @property string $unit_code
 * @property string $discount_amount
 * @property string $discount_percent
 * @property double $unit_price
 * @property string $total_price
 * @property string $qty_received_by_grn
 * @property string $supplier_part_code
 * @property string $currency_code
 * @property string $payment_term
 * @property string $lead_time
 * @property string $delivery_date
 * @property string $purchase_requisition_number
 */
class PoDetail extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return PoDetail the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'po_detail';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('unit_price', 'numerical'),
			array('part_name, payment_term', 'length', 'max'=>50),
			array('qty', 'length', 'max'=>18),
			array('discount_amount, discount_percent, total_price, qty_received_by_grn, lead_time, purchase_requisition_number', 'length', 'max'=>19),
			array('po_number, part_code, description, unit_code, supplier_part_code, currency_code, delivery_date', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, po_number, part_code, part_name, description, qty, unit_code, discount_amount, discount_percent, unit_price, total_price, qty_received_by_grn, supplier_part_code, currency_code, payment_term, lead_time, delivery_date, purchase_requisition_number', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'po_number' => 'Po Number',
			'part_code' => 'Part Code',
			'part_name' => 'Part Name',
			'description' => 'Description',
			'qty' => 'Qty',
			'unit_code' => 'Unit Code',
			'discount_amount' => 'Discount Amount',
			'discount_percent' => 'Discount Percent',
			'unit_price' => 'Unit Price',
			'total_price' => 'Total Price',
			'qty_received_by_grn' => 'Qty Received By Grn',
			'supplier_part_code' => 'Supplier Part Code',
			'currency_code' => 'Currency Code',
			'payment_term' => 'Payment Term',
			'lead_time' => 'Lead Time',
			'delivery_date' => 'Delivery Date',
			'purchase_requisition_number' => 'Purchase Requisition Number',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('po_number',$this->po_number,true);
		$criteria->compare('part_code',$this->part_code,true);
		$criteria->compare('part_name',$this->part_name,true);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('qty',$this->qty,true);
		$criteria->compare('unit_code',$this->unit_code,true);
		$criteria->compare('discount_amount',$this->discount_amount,true);
		$criteria->compare('discount_percent',$this->discount_percent,true);
		$criteria->compare('unit_price',$this->unit_price);
		$criteria->compare('total_price',$this->total_price,true);
		$criteria->compare('qty_received_by_grn',$this->qty_received_by_grn,true);
		$criteria->compare('supplier_part_code',$this->supplier_part_code,true);
		$criteria->compare('currency_code',$this->currency_code,true);
		$criteria->compare('payment_term',$this->payment_term,true);
		$criteria->compare('lead_time',$this->lead_time,true);
		$criteria->compare('delivery_date',$this->delivery_date,true);
		$criteria->compare('purchase_requisition_number',$this->purchase_requisition_number,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}